﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectOptions.aspx.cs" Inherits="LHWebApp.SelectOptions" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>选择子系统</title>
    <script type="text/javascript" src="libHuabao/jquery/jquery.min.js"></script>
    <%--<link rel="stylesheet" type="text/css" href="libHuabao/jquery/jquery.min.js" />--%>
    <script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="ext/ext-all.js"></script>
    <script type="text/javascript" src="ext/ext-lang-zh_CN.js"></script>

    <link rel="stylesheet" type="text/css" href="css/selectOptions.css" />
    <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css"/>
</head>
<body>
    <div id="container">
<form style="position:absolute;top:110px;left:450px;font-size: 20px;" action="" method="get"> 
<label>项目：</label> 
<select style="font-size: 20px;" name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)"> 
<%--<option value="yx">应县</option> 
<option value="plq">平鲁区</option> 
<option value="syx">山阴县</option> 
<option value="scx">神池县</option> --%>
</select> 
</form> 
        <div class="select_box">
            <a href="javascript:;" class="select_btn" id="select_btn1">道路机扫作业</a>
            <a href="javascript:;" class="select_btn" id="select_btn2">道路人工作业</a>
            <a href="javascript:;" class="select_btn" id="select_btn3">垃圾作业</a>
            <a href="javascript:;" class="select_btn" id="select_btn6">公厕维保作业</a>
            <a href="javascript:;" class="select_btn" id="select_btn4">车务机务</a>
            <a href="javascript:;" class="select_btn" id="select_btn5">综合混合显示</a>
            
            <a href="" class="select_btn" id="logout">退出</a>
        </div>
    </div>

    <script type="text/javascript">
        var loginUsername = '<%=userInfo.loginUsername%>';
        var loginPassword = '<%=userInfo.loginPassword%>';
        var selectUserInfo;
        var selectUserInfoCurrentID = '<%=userInfo.ClientNo%>';
        var firstClientNo = '<%=userInfo.firstClientNo%>';
        document.getElementById('logout').onclick = function () {
            //            Ext.MessageBox.confirm('系统提示', '你确定要注销吗?', function (btn) {
            //                if (btn == 'yes') {
            Ext.Ajax.request({
                url: './Services/loginout.aspx',
                success: function (request) {
                },
                failure: function () {
                    Ext.Msg.alert('注销失败!', '请重新尝试');
                }
            });
            //                }
            //            });

        }
        document.getElementById('select_btn1').onclick = function () {
            //            window.open('http://111.160.78.62:8088/WebGisNew/Services/login.aspx?loginUsername=' + loginUsername + '&loginPassword=' + loginPassword;
            window.open("main.aspx?currentService=1");
        }
        document.getElementById('select_btn2').onclick = function () {
            if (loginUsername == "yx") { window.open('http://111.160.78.62:4450/cleaner?ClientNo=' + selectUserInfoCurrentID); }
            if (loginUsername == "dc" || loginUsername == "glx") { window.open('http://111.160.78.62:4453/cleaner?ClientNo=' + selectUserInfoCurrentID); }
        }
        document.getElementById('select_btn4').onclick = function () {
            if (loginUsername == "yx") { window.open('http://111.160.78.62:4450/traffic?ClientNo=' + selectUserInfoCurrentID); }
            if (loginUsername == "dc" || loginUsername == "glx") { window.open('http://111.160.78.62:4453/traffic?ClientNo=' + selectUserInfoCurrentID); }

        }
        document.getElementById('select_btn3').onclick = function () {
            window.open("main.aspx?currentService=3");
        }
        document.getElementById('select_btn5').onclick = function () {
            window.open("main.aspx?currentService=5");
        }
        document.getElementById('select_btn6').onclick = function () {
            window.open("main.aspx?currentService=6");
        }
        getLoginInfo();
        function getLoginInfo() {
            // 数据源
            var placeData = new Ext.data.Store({
                url: "./Json/JsonGetVehicleCurrentInfoList.ashx",
                //        pageSize: 2,
                autoSync: false,
                reader: new Ext.data.JsonReader({ root: 'data' }, Ext.data.Record.create([
    { name: 'CLIENT_NO' },
    { name: 'CLIENT_NAME' },
    { name: 'UID' },
    { name: 'PWD' }
    ]))
            });

            placeData.load({
                params: { clientNo: firstClientNo, op: 'GetLoginInfoSelectOptions' }, //2019.09.20 zx
                autoLoad: true,
                callback: function (records, options, success) {
                    if (success) {
                        selectUserInfo = records;
                        changeUser(selectUserInfo[0].get("UID"), selectUserInfo[0].get("PWD"));
                        updateSelectLoginInfo();
                        //                        for (var i = 0; i <= records.length - 1; i++) {
                        //                            window.frames["monitor"].createMarkerPlaceCY(records[i].get("LONGITUDE"), loginUsername[i].get("LATITUDE"), "餐饮", records[i].get("Name"), "overText");
                        //                        }
                    }
                }
            });
        }
        function updateSelectLoginInfo() {

            //首先是先拿到select标签的ID

            var $selected = $("#jumpMenu");

            $selected.empty(); //清空内容

            var obj = ''; //创建一个全局变量，用来存储接下来循环里的内容

            //$("#jumpMenu").append('<option value="-1">' + loginUsername + '</option>'); //给select标签内添加默认内容

            for (var i = 0; i < selectUserInfo.length; i++) {//通过for循环来解析数组

                //将option作为拼接字符串添加到变量obj中
                var no = selectUserInfo[i].get("CLIENT_NO");
                var name = selectUserInfo[i].get("CLIENT_NAME");
                if (selectUserInfoCurrentID == no) {
                    obj = "<option class='option' value='" + no + "'>" + name + "</option>" + obj;
                } else {
                    obj += "<option class='option' value='" + no + "'>" + name + "</option>";
                }
                

            }

            //将循环内的字符串追加到select标签中

            $("#jumpMenu").append(obj);

        }

        function MM_jumpMenu(targ, selObj, restore) { //v3.0
            //            alert(selObj.options[selObj.selectedIndex].value);
            //            eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
            //            if (restore) selObj.selectedIndex = 0;
            if (selObj.options[selObj.selectedIndex].value != "-1") {
                for (var i = 0; i < selectUserInfo.length; i++) {//通过for循环来解析数组

                    //将option作为拼接字符串添加到变量obj中
                    if (selectUserInfo[i].get("CLIENT_NO") == selObj.options[selObj.selectedIndex].value) {
                        changeUser(selectUserInfo[i].get("UID"), selectUserInfo[i].get("PWD"));
                    }
                    //                    obj += "<option class='option' value='" + loginUsername[i].get("CLIENT_NO") + "'>" + loginUsername[i].get("CLIENT_NAME") + "</option>";

                }

            }
        }
        function changeUser(id, pwd) {
            Ext.Ajax.request({
                //url: './Services/CommonService.asmx/SendMessage',
                url: './Services/login.aspx',
                params: {
                    loginUsername: id, loginPassword: id, isLogin:"5566"
                },
                success: function (records, options) {
                    var str = records.responseText.split(',');
                    loginUsername = str[0];
                    selectUserInfoCurrentID = str[1];
//                    selectUserInfo[0].get("UID")
//                    alert("项目切换成功");
                    //                    Ext.MessageBox.alert("提示", "项目切换成功");
//                    Ext.MessageBox.alert("提示", "项目切换成功");
                },
                failure: function () {
//                    alert("项目切换失败");
                    //                    Ext.MessageBox.alert("提示", "项目切换失败");
                    Ext.MessageBox.alert("提示", "项目切换失败");
                }
            });
        }
    </script>
</body>
</html>

